package com.example.backend.Controller;


import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
// @Component 作用是把当前类标记为组件，在spring容器中创建对象
@Controller
public class ThymeleafHelloController {
    // @GetMapping("/XXX") 作用 响应指定的URL
//    @GetMapping("/tyhello")
    // @RequestParam("XXX")  作用是获取URL中的某一指定参数的值
    @RequestMapping(path = "/tyhello", method = RequestMethod.GET, params = {"name"})
    public String helloThymeleaf(@RequestParam("name") String naem, Model model){
        model.addAttribute("name",naem);
        model.addAttribute("HtmlCode","<a href='https://www.baidu.com/' >#</a>");

        return "tyhello";// 返回thymeleaf模板名称 【文件名称】
}

}
